#include "UserManager.h"

UserManager::UserManager()
{
}

void UserManager::loadUserList()
{
	/// TODO: load users from database
}

QList<User*> UserManager::getUserList()
{
	return _users;
}

bool UserManager::addUser(User* user)
{
	_users.append(user);
	/// TODO: add user to database
}

void UserManager::changeUserState(int id, User::UserState state)
{
	foreach(User* user, _users){
		if(user->getId() == id){
			user->setState(state);
			return;
		}
	}
}

User* UserManager::getUserById(int id)
{
	foreach(User* user, _users){
		if(user->getId() == id){
			return user;
		}
	}
	return NULL;
}
